//作用，弹出部门的选择层里面是部门的树形表格
//前提，在layui.use里面去调用 必须要依赖layui
/**
 * idDom是提交到后台的表单的dom input
 * showDom是显示的dom  input
*/
function openDeptSelectLayer(idDom,showDom){
	 layui.use(['treeTable'], function () {
		 var treeTable=layui.treeTable;
		 var tbIns;
		 var index = layer.open({
		     title: '选择部门',
		     type: 1,  
		     shade: 0.2,
		     maxmin:true,
		     shadeClose: true,
		     area: ['800px', '500px'],
		     content: '<div stype="padding:5px;"><table class="layui-table" id="deptTableSelId" lay-filter="deptTableSelFilter"></table></div>',
		 	 success:function(){
		 		// 渲染表格
		 		 tbIns = treeTable.render({
		 		    elem: '#deptTableSelId',
		 		    tree: {
		 		        iconIndex: 2,
		 				isPidData:true,
		 				openName:'spread'
		 		    },
		 		    cols: [
		 		        {type: 'numbers'},
		 		        {type: 'radio'},
		 		        {field: 'title', title: '部门名称', width: 200},
		 				{field: 'id', title: '部门ID', align:'center'},
		 				{field: 'pid', title: '部门PID', align:'center'},
		 				{field: 'address', title: '部门地址',align:'center'},
		 				{field: 'remark', title: '部门备注', align:'center'},
		 		    ],
		 			reqData: function(data, callback) {
		 				$.get(api+"dept/loadAllDept?available=1", function (res) {
		 					callback(res.data);
							// 设置选中数据
							var  pid=idDom.val();
							if(pid){
								tbIns.setChecked(pid);  // 设置选中数据
							}
		 				});
		 			}
		 		});
				
				
		 	},
			btn:['确定','关闭'],
			btnAlign:'c',
			yes:function(index){
				var checkStatus=tbIns.checkStatus(); 
				if(checkStatus.length>0){
					var data=checkStatus[0];
					idDom.val(data.id);
					showDom.val(data.title);
					layer.close(index);
				}else{
					layer.msg('请选择部门');
				}
			}
		 });
	 });
}






